package cn.wfmiss.spring6.iocxml.di;


/**
 * Created with IntelliJ IDEA.
 *
 * @Author: wfmiss
 * @Date: 2023/12/31/12:12
 * @Description:
 */
public class Book {
    private String bname;
    private String author;

    @Override
    public String toString() {
        return "Book{" +
                "bname='" + bname + '\'' +
                ", author='" + author + '\'' +
                ", others='" + others + '\'' +
                '}';
    }

    public Book(String bname, String author, String others) {
        this.bname = bname;
        this.author = author;
        this.others = others;
        System.out.println("有参数构造执行了。。。。");

    }

    public String getOthers() {
        return others;
    }

    public void setOthers(String others) {
        this.others = others;
    }

    private String others;

    public Book() {
        System.out.println("无参数构造执行了。。。。");

    }


    // 生成set方法
    public String getBname() {
        return bname;
    }

    public void setBname(String bname) {
        this.bname = bname;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public static void main(String[] args) {
        // set方法注入
        Book book = new Book();
        book.setBname("java");
        book.setAuthor("詹姆斯·高斯林");
        System.out.println(book);
    }

    // 通过构造器注入
    // Book book1=new Book("C++","贾尼·斯特劳斯特卢普");

}
